package com.yaowk.authc.model.page;


import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Record;
import com.yaowk.common.model.Page;

/**
 * @authc yaowk
 * 2017/4/25
 */
public class PageOne extends Page {

    private Integer platformId;
    private Integer userType;
    private Long beginTime;
    private Long endTime;
    private String keyword;

    public Integer getPlatformId() {
        return platformId;
    }

    public void setPlatformId(Integer platformId) {
        this.platformId = platformId;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public Long getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Long beginTime) {
        this.beginTime = beginTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    @Override
    public Record toRecord() {
        Record record = new Record()
                .set("platformId", platformId)
                .set("userType", userType)
                .set("beginTime", beginTime)
                .set("endTime", endTime);
        if (StrKit.notBlank(keyword)) {
            String keyword = "%" + this.keyword + "%";
            record.set("name", keyword)
                    .set("userCode", keyword);
        }
        return record.removeNullValueColumns();
    }
}
